<?php
/**
 * Author：晴天 QQ：1186258278
 * Creation：2020/5/30 19:25
 * Filename：set.php
 * 账号密码绑定
 */

$title = '信息管理';
include 'header.php';
?>


<div class="container-fluid">
    <div class="row">
        <div class="col-xl-12">
            <div class="card">
                <div class="card-header">
                    信息管理
                </div>
                <div class="card-body">
                    <div class="card-body">
                        <form class="form-horizontal layui-form">
                            <div class="form-group mb-3">
                                <label for="example-input-normal" style="font-weight: 500">用户名，可自由修改</label>
                                <input type="text" name="name" lay-verify="required"
                                       class="form-control"
                                       value="<?= $USERDATA['name'] ?>"
                                       placeholder="请填写新的手机号">
                            </div>
                            <div class="form-group mb-3">
                                <label for="example-input-normal" style="font-weight: 500">绑定QQ，用于登陆或绑定账号</label>
                                <input type="number" name="qq" lay-verify="required"
                                       class="form-control"
                                       value="<?= $USERDATA['qq'] ?>"
                                       placeholder="请填写新的QQ">
                            </div>

                            <div class="form-group mb-3">
                                <label for="example-input-normal" style="font-weight: 500">绑定手机号，用于登陆或绑定账号</label>
                                <input type="number" name="mobile" lay-verify="required"
                                       class="form-control"
                                       value="<?= $USERDATA['mobile'] ?>"
                                       placeholder="请填写新的手机号">
                            </div>

                            <div class="form-group mb-3">
                                <label for="example-input-normal" style="font-weight: 500">登陆账号，主站开启了账号密码登陆时可使用</label>
                                <input type="text" name="username" lay-verify="required"
                                       class="form-control"
                                       value="<?= $USERDATA['username'] ?>"
                                       placeholder="请填写新的登陆账号">
                            </div>

                            <div class="form-group mb-3">
                                <label for="example-input-normal" style="font-weight: 500">登陆密码，主站开启了账号密码登陆时可使用</label>
                                <input type="text" name="password"
                                       class="form-control"
                                       value=""
                                       <?=($USERDATA['password']==''?'lay-verify="required"':'')?>
                                       placeholder="留空不修改,请填写新的密码">
                            </div>

                            <button type="submit" lay-submit lay-filter="withdrawal"
                                    class="btn btn-block btn-xs btn-outline-success">保存信息
                            </button>
                        </form>
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
<?php
include 'bottom.php';
?>

<script>

    layui.use(['form', 'table', 'upload'], function () {
        var form = layui.form;
        var table = layui.table;
        var upload = layui.upload;
        form.on('submit(withdrawal)', function (data) {
            layer.msg('正在保存中...', {
                time: 999999,
                icon: 16
            });

            layer.open({
                title: '操作确认',
                content: '是否要执行此操作？',
                btn: ['确认执行', '取消'],
                icon: 3,
                btn1: function (layero, index) {
                    $.ajax({
                        type: "POST",
                        url: 'ajax.php?act=user_set',
                        data: data.field,
                        dataType: "json",
                        success: function (data) {
                            if (data.code == 1) {
                                layer.alert(data.msg, {
                                    icon: 1, end: function (layero, index) {
                                        location.reload();
                                    }
                                })
                            } else {
                                layer.msg(data.msg)
                            }
                        },
                        error: function () {
                            layer.alert('失败！');
                        }
                    });
                }
            });


            return false;
        });
    });

</script>
